package com.example.vaccine.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.vaccine.VO.PageVO;
import com.example.vaccine.entity.CheckRecords;
import com.example.vaccine.mapper.CheckRecordsMapper;
import com.example.vaccine.service.CheckRecordsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Coisn
 * @since 2025-06-12
 */
@Service
public class CheckRecordsServiceImpl extends ServiceImpl<CheckRecordsMapper, CheckRecords> implements CheckRecordsService {

    @Override
    public PageVO searchRecords(String vaccineNumbering, int page, int size) {
        QueryWrapper<CheckRecords> wrapper = new QueryWrapper<>();

        if (vaccineNumbering != null && !vaccineNumbering.trim().isEmpty()) {
            wrapper.like("vaccine_numbering", vaccineNumbering.trim());
        }

        Page<CheckRecords> resultPage = new Page<>(page, size);
        this.page(resultPage, wrapper);

        PageVO pageVO = new PageVO();
        pageVO.setData(resultPage.getRecords());
        pageVO.setTotal(resultPage.getTotal());
        return pageVO;
    }


}
